package com.shark.teach;

@FunctionalInterface
interface Foo
{
    //public void hello();

    public int add(int x ,int y);

    default int sub(int x ,int y)
    {
        return x - y;
    }
}

/**
 * @auther shark
 * @create 2023-10-06 16:46
 *
 * lambde express
 *
 * 拷贝小括号，写死右箭头，落地大括号
 */
public class LambdaDemo
{
    public static void main(String[] args)
    {
        /*Foo foo = new Foo()
        {
            @Override
            public void hello()
            {
                System.out.println("----come in java0620");
            }
        };
        foo.hello();*/

        /*Foo foo = () -> {System.out.println("----come in java0620 v2");};
        foo.hello();*/

        Foo foo = (int x ,int y) -> {
            System.out.println("---come in add method");
            int result = x + y;
            return result;
        };
        System.out.println(foo.add(3, 5));

        System.out.println(foo.sub(10, 5));
    }
}
